<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">

		<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
		<link rel="stylesheet" href="css/login.css" />
		<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
		<script src="bootstrap/js/bootstrap.min.js"></script>

		<script>
			
		</script>
	</head>

	<body>
	<h1>欢迎来到系统首页</h1>
		<div id="_start" style="left: 350px; height: 520px; width: 400px;border: 1px solid rgba(0,0,0,.25);">
			
			<br> 
			
			<!-- 会员注册 -->
			<div id="regist_container" style="display: block;">
				<div id="form_container2" style="padding-top: 25px;">
					
					
					
					<input type="text" class="form-control"  placeholder="用户名" id="regist_account">
					
					<!--<button id="getVCode" type="button" class="btn btn-success" >获取验证码</button>-->
					<input id="getVCode" type="button" class="btn btn-success" value="退出登录" onclick="logout(this)">

				</div>
				
			</div>
		</div>
	</body>
	<script type="text/javascript">
		
		function logout(thisBtn) {
			console.log('logout');	
		  $.ajax({
            type: 'GET',
			 headers: {
                Accept: "application/json; charset=utf-8",
                "accessToken": sessionStorage.getItem("token")
            },
			
			async:false,
            url: "/api/user/logout/",
            data: {
               
            },
            success: function (msg) {
                  console.log('msg',msg);
                if (msg.status == 200) {
                    
                  window.location.href="login.html"; 
                } 
            },
            dataType: "json"
        });
		}
		
		
		function info(thisBtn) {
		var token=sessionStorage.getItem("token")
			console.log('info');
            console.log('token',token);		
		if(info == null||info == ''){
		window.location.href="login.html"; 
		return ;
		}	
		 $.ajax({
            type: 'GET',
			 headers: {
                Accept: "application/json; charset=utf-8",
                "accessToken": token
            },
			xhrFields: {
        withCredentials: true
    },
            url: "/api/user/info/"+token,
            data: {
               
            },
            success: function (msg) {
                  console.log('msg',msg);
                if (msg.status == 200) {
                    $('#regist_account').val(msg.data);
                  //window.location.href="login.html"; 
                } else if(msg.status == 401){
				alert('小伙计么登录呢，想啥呢');
				 window.location.href="login.html"; 
				}else {
					alert(msg.msg);
					 window.location.href="login.html"; 
				}
            },
            dataType: "json"
        });
		}
		

		info();
	
	</script>

</html>